package com.autumn.cloud.demo.provider.controllers;

import com.autumn.cloud.demo.common.constants.DemoServiceProviderUrlConstants;
import com.autumn.cloud.demo.common.model.UserInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;

/**
 * <p>
 * </p>
 *
 * @description TODO
 * @author: 老码农
 * @create: 2020-12-10 18:05
 **/
@RestController
@Slf4j
public class UserController {

    @Value("${spring.application.name}")
    private String appName;

    @Value("${eureka.instance.instance-id}")
    private String instanceId;

    /**
     * 用户信息
     *
     * @return
     */
    @GetMapping(path = DemoServiceProviderUrlConstants.USER_INFO_URL)
    public UserInfo userInfo() {
        UserInfo userInfo = new UserInfo();
        userInfo.setTime(LocalDateTime.now());
        userInfo.setName("测试用户");
        userInfo.setSex("系统");
        userInfo.setAgx(20);
        userInfo.setServiceName(this.appName + " " + this.instanceId);
        userInfo.setMsg("原始服务器");
        log.info("用户信息请求--原始服务器");
        return userInfo;
    }
}
